#include <lpc23xx.h>
#include "LCD.h"
unsigned int flasher = 0x0000000; 	
int main (void)
{
    
unsigned int delay; //
	/* Reset all GPIO pins to default: primary function */
    PINSEL0 = 0x00000000;
    PINSEL1 = 0x00000000;
    PINSEL2 = 0x00000000;
    PINSEL3 = 0x00000000;
    PINSEL4 = 0x00000000;
    PINSEL5 = 0x00000000;
    PINSEL6 = 0x00000000;
    PINSEL7 = 0x00000000;
    PINSEL8 = 0x00000000;
    PINSEL9 = 0x00000000;
    PINSEL10 = 0x00000000;
    
    IODIR0 = 0x00000000;
    IODIR1 = 0x00000000;
	  IOSET0 = 0x00000000;
    IOSET1 = 0x00000000;
    
    FIO0DIR = 0x00000000;
    FIO1DIR = 0x00000000;
    FIO2DIR = 0x00000000;
    FIO3DIR = 0x00000000;
    FIO4DIR = 0x00000000;
    
    FIO0SET = 0x00000000;
    FIO1SET = 0x00000000;
    FIO2SET = 0x00000000;
    FIO3SET = 0x00000000;
    FIO4SET = 0x00000000;					
  
   
PINSEL4 |=  0x01      //Connect PWM1.1 to pin 2.0
        |   0x01<<2   //Connect PWM1.2 to pin 2.1
        |   0x01<<4   //Connect PWM1.3 to pin 2.2
        |   0x01<<6   //Connect PWM1.4 to pin 2.3
        |   0x01<<8   //Connect PWM1.5 to pin 2.4
        |   0x01<<10; //Connect PWM1.6 to pin 2.5
            
PWM1PCR |=  0x01<<9	  //Enable PWM 1 output
        |   0x01<<10  //Enable PWM 2 output
        |   0x01<<11  //Enable PWM 3 output
        |   0x01<<12  //Enable PWM 4 output
        |   0x01<<13  //Enable PWM 5 output
        |   0x01<<14; //Enable PWM 6 output
        
PWM1MCR = 0x00000002;	//On match with timer reset the counter
PWM1PR 	 = 0x00000000;	//Load prescaler
PWM1MR0 = 60000000/4;	//set cycle rate to one second
PWM1MR1 = 60000000/8;	//set duty cycle to 50%
PWM1MR2 = 60000000/8;	//set duty cycle to 50%
PWM1MR3 = 60000000/8;	//set duty cycle to 50%
PWM1MR4 = 60000000/8;	//set duty cycle to 50%
PWM1MR5 = 60000000/8;	//set duty cycle to 50%
PWM1MR6 = 60000000/8;	//set duty cycle to 50%
PWM1LER = 0x0000007F;	//enable shadow latch for match 0 - 6 
PWM1TCR = 0x00000002;	//Reset counter and prescaler 
PWM1TCR = 0x00000009;	//enable counter and PWM, release counter from reset

    lcd_init();					   //
	lcd_clear();				  //
	set_cursor(2,0);			   // Agaf=/
    lcd_print("PWM Example");	 //
while(1)
  {
    ;
  }


    
return (0);    
}
